A data processing apparatus may include one or more processing elements that perform program tasks, such as processes or threads, by executing a program of instructions. Execution of the instructions alters the state of the processing element. A task context is the minimal set of data used by a task that must be saved in order to enable a task to be interrupted, and later continued from the same point. A context may include register values, configuration settings, debug register values, etc.
A program task, such as an execution thread or process, can be executed by processing elements in successive portions, possibly interspersed with portions of execution of other program tasks. Execution can be passed from one processing element to another. To enable this, a process referred to as context switching may take place.
In a context switch, each processing element is configured to save context data relating to a program task following execution of that program task by that processing element; and to load context data, previously saved by that processing element or another of the processing elements, at resumption of execution of a program task.
Context cloning, or the generation of a new context, requires allocation of storage for context data and the storing of initial values of the context data in the allocated storage. This enables a new task to be executed by the processing core.
Some processors have dedicated registers (shadow registers) for storing a context and enabling switching between two processes. However, processing cores may be required to execute a large number of threads or processes in parallel. In such case, allocation and initialization of memory is required each time a new context is to be saved. Memory allocation is usually performed by an operating system (OS), so the performance of the data processing apparatus is impaired.
Accordingly, there is a need for an improved data processing apparatus that provides fast context cloning.